<?php 
	//Database
	require $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/database.php';
	
	//If data exist
	if (isset ($_POST['username']) &&
		isset($_POST['password']) &&
		isset($_POST['email']) &&
		isset($_POST['name']) &&
		isset($_POST['birth']) &&
		isset($_POST['gender']) &&
		isset($_POST['location']) ) {
		
		//Clears from injection
		$username	= mysql_real_escape_string($_POST['username']);
		$email		= mysql_real_escape_string($_POST['email']);
		$realname	= mysql_real_escape_string($_POST['name']);
		$birth		= mysql_real_escape_string($_POST['birth']);
		$location	= mysql_real_escape_string($_POST['location']);

		//Get other parameter
		$gender		= $_POST['gender'];
		$password	= md5($_POST['password']);

		//Add to database
		mysql_query("INSERT INTO users (username, password, email)
			VALUES ('$username', '$password', '$email')") or die (mysql_error());
	}
	
	//Start HTML part
	require $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/doctype.php';
?>
	<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>deviantPIC - Registration result</title>
    </head>
    <body>
		<!-- Header -->
		<?php require $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/header.php'; ?>

		<!-- Content -->
		<div id="body">
			<h2>Registration Result</h2>
			<div id="registration-result">
				<?php
					echo "	Thank You
							<div id='registration-handler'>
								Registration Success. Please wait here while we transfer you back home.
							</div>";
					echo "<meta http-equiv='refresh' content='3; /deviantpic/index.php'/>";
				?>
			</div>
		</div>

		<!-- Footer -->
		<?php require $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/footer.php'; ?>
    </body>
</html>

